<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <meta name="format-detection"content="telephone=no, email=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" /><!-- 删除苹果默认的工具栏和菜单栏 -->
    <meta name="apple-mobile-web-app-status-bar-style" content="black" /><!-- 设置苹果工具栏颜色 -->
    <meta name="renderer" content="ie-comp">
    <meta name="renderer" content="ie-stand">
    <meta name="renderer" content="webkit"> 
    <meta name="keywords" content="耀盛中国,耀盛智投,理财产品,智选财富,耀盛智投官网"/>
    <meta name="description" content="耀盛智投为耀盛中国旗下理财产品智选平台。专注于为大众富裕阶层、精英个人、中产阶级家庭、合规机构等提供定制化资产配置咨询推荐服务，帮助客户实现财富的增值。" />
    <title>修改登录密码</title>
    <script src="../../lib/js/ftSize.js"></script>
    <link rel="stylesheet" href="../../lib/css/_base.css">
    <link rel="stylesheet" href="../../lib/css/publicBubb.css">
    <link rel="stylesheet" type="text/css" href="../../lib/css/forgotPassword.css">
<style>
    #modifymMblie{
        font-size:.36rem;
        text-align: left;
        line-height: .7rem;
    }
</style>
</head>
<body>
    <!-- 验证手机号 -->
    <div class="forgot_one" id="modifyloginOne">
        <div class="forgot">
            <h1>验证手机号</h1>
            <div class="F_padding">
                <div class="F_one F_bottom" id="modifymMblie">
                </div>
                <div class="F_yzm">
                    <input type="text" name="" placeholder="请输入短信验证码" class="yzm" id="modifymSms" maxlength="6">
                    <span id="getSms" onClick="getMess()">获取验证码</span>
                </div>
            </div>    
        </div>
        <div class="wraning1"></div>
        <div class="F_btn_n1" id="moLoginOne" onClick="modifyOne()">下一步</div>
    </div>
   
    <!-- 设置新密码 -->
    <div class="forgot_tow" id="modifyloginTwo">
            <div class="forgot">
                <h1>设置新密码</h1>
                <div class="F_padding">
                    <div class="F_one F_bottom">
                        <input type="password" name="" placeholder="请输入新密码" id="modifymNpwd">
                    </div>
                    <div class="F_one">
                        <input type="password" name="" placeholder="请确认新密码" id="modifymCpwd">
                    </div>
                </div>
            </div>
            <div class="wraning2"></div>
            <div class="F_btn_n1" id="moLoginTwo" onClick="modifyTwo()">下一步</div>
    </div>
    <!-- 弹窗 -->
    <div class="maskWrap" id="modifyloginMask">
        <div class="maskLayer">
            <div class="maskImg"></div>
            <div class="maskTitle">密码修改成功！</div>
            <div class="maskbtnGroup">
                <a href="index.html"> <span class="winBg"> 确定</span></a>
            </div>  
        </div>
    </div>
<script src="../../lib/js/jquery.min.js"></script>
<script src="../../lib/js/public-header.js"></script>
<script>
    var validCode=true;
    var isRegister;
    let wpuserInfo = window.sessionStorage.getItem("wpuserInfo");//是否有登录信息
    let userPhone=JSON.parse(wpuserInfo).userPhone.substring(0,3)+"****"+JSON.parse(wpuserInfo).userPhone.substring(9,11); 
    var messError;//短信验证码错误信息
    let wpuserToken=window.sessionStorage.getItem('wpuserToken');
$('#modifymMblie').text(userPhone)
$('#modifymSms').focus(function(){
    $('.wraning1').text('')
})
$('#modifymCpwd').focus(function(){
    $('.wraning2').text('')
})
$('#modifymNpwd').focus(function(){
    $('.wraning2').text('')
})
//弹窗
$('#modifyloginMask').hide()
/* 手机验证码 */

    function smsJson(mobile) {
        var json = {
            "faceCode":"common/sendSms",
            "token":"",    
            "clientInfo":"W,100,IE8",  
            "requestTime": formatDateTime(startTime),
            "body":{
                "mobile":mobile,
            }
        }
        return json;
    }
/* 第一步验证信息 */
function resetloginOne(mobile,smsCode,loginPwd,newLoginPwd) {
    var json = {
        "faceCode":"user/resetLoginPwd",
        "token":wpuserToken,
        "clientInfo":"W,100,IE8",
        "requestTime": formatDateTime(startTime),
        "body":{
            "mobile":mobile,
            "smsCode":smsCode,
            "loginPwd":loginPwd,
            "confirmPwd":newLoginPwd,
            
        }
    }
    return json;
}
/* 获取短信验证码 */
function getMess(){
    let modifymMblie=JSON.parse(wpuserInfo).userPhone;
    var time=60;
    var $code=$(this);
    $.ajax({  
            type: "POST",
            url: httpServer+"common/sendSms",
            headers:{
                'Access-Control-Allow-Origin':'*'
            }, 
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(smsJson(modifymMblie)),
            dataType: "json",
            success: function (ismessAuth) {  
                if(ismessAuth.resCode!='0'){
                    $('.wraning1').text(ismessAuth.errorMsg)
                }else{
                    if (validCode) {
                        validCode=false;
                        var t=setInterval(function  () {
                            time--;
                            $('#getSms').html(time+"秒");
                            if (time==0) {
                                clearInterval(t);
                                $('#getSms').html("获取验证码");
                                validCode=true;
                            }
                        },1000)
                    }
                }
            },
            error: function(error){  
            
            }    
        }); 
}
/* 忘记密码第一步 判断是否实名认证 手机号/短信验证码*/
function modifyOne(){
    let modifymSms=$('#modifymSms').val().trim();
    if(modifymSms!=''){
        $.ajax({  
            type: "POST",
            url: httpServer+"user/resetLoginPwd",
            headers:{
                'Access-Control-Allow-Origin':'*'
            }, 
            async:false,
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(resetloginOne(JSON.parse(wpuserInfo).userPhone,modifymSms,'','')),
            dataType: "json",
            success: function (isModify) {  
                if(isModify.resCode!='0' ){
                   
                    $('.wraning1').text(isModify.errorMsg)
                }else{
                    $('#modifyloginOne').hide()
                    $('#modifyloginTwo').show()
                }
            },
            error: function(error){  
                console.log(error,1);  
            }    
        }); 
    }else{
        $('.wraning1').text('请输入短信验证码')
    }
} 

/* 忘记密码第二步 新密码/确认密码*/
function modifyTwo(){
    let modifymSms=$('#modifymSms').val().trim();
    let modifymCpwd=$('#modifymCpwd').val().trim();//旧密码
    let modifymNpwd=$('#modifymNpwd').val().trim();//新密码
    if(modifymNpwd!=''){
        if(payPwd.test(modifymNpwd)){
            if(modifymNpwd!='' || modifymOpwd!=modifymNpwd && payPwd.test(modifymNpwd)){
                $.ajax({  
                    type: "POST",
                    url: httpServer+"user/resetLoginPwd",
                    headers:{
                        'Access-Control-Allow-Origin':'*'
                    }, 
                    async:false,
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(resetloginOne(JSON.parse(wpuserInfo).userPhone,modifymSms,modifymNpwd,modifymCpwd)),
                    dataType: "json",
                    success: function (isModify) {  
                       if(isModify.resCode!='0' ){
                        $('.wraning2').text(isModify.errorMsg)
                       }else{ 
                            $('#modifyloginMask').show()
                       }
                       
                    },
                    error: function(error){  
                        console.log(error,3);  
                    }    
                }); 
            }else{
                $('.wraning2').text('请输入6~16位字母数字组合!')
            }
        }else{
            $('.wraning2').text('请输入6~16位字母数字组合!')
        }
    }else{
        $('.wraning2').text('请输入6~16位字母数字组合!')
    }
}  

</script>

</body>
</html>